﻿using AnyCAD.Foundation;
using AnyCAD.WPF.ViewModel;
using Rapid.Sketch.Plugin.Model;
using System.ComponentModel;

namespace Rapid.Sketch.Plugin.ViewModel
{
    public class SectionBarViewModel : ElementViewModel
    {
        SectionBarModel Model = new SectionBarModel();
        public SectionBarViewModel(ShapeElement instance, Document doc, PropertyChangedEventHandler callback)
            :base(instance, doc)
        {
            Model.Load(instance);

            PropertyChanged += callback;
        }

        public double InnerRadius {
            get => GetProperty(nameof(InnerRadius), Model.InnerRadius);
            set => SetProperty(nameof(InnerRadius), ref Model.InnerRadius, value, () => { return value > 0; }, nameof(OutterRadius));
        }
        public double Thickness { 
            get => GetProperty(nameof(Thickness), Model.Thickness);
            set => SetProperty(nameof(Thickness), ref Model.InnerRadius, value, () => { return value > 0; }, nameof(OutterRadius));
        }

        public double OutterRadius
        {
            get => InnerRadius + Thickness;
        }
        public double Length { 
            get => GetProperty(nameof(Length), Model.Length);
            set => SetProperty(nameof(Length), ref Model.InnerRadius, value, () => { return value > 0; });
        }
    }
}
